In [1]:
#import libraries

import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import plotly.io as pio
pio.templates.default = "plotly_white"
In [2]:
#loading Dataset

data = pd.read_csv(r'C:\Users\Venkatesh\Downloads\t20-world-cup-22.csv')
print(data.head())
              venue        team1        team2     stage  toss winner  \
0               SCG  New Zealand    Australia  Super 12    Australia   
1     Optus Stadium  Afghanistan      England  Super 12      England   
2  Blundstone Arena      Ireland    Sri lanka  Super 12      Ireland   
3               MCG     Pakistan        India  Super 12        India   
4  Blundstone Arena   Bangladesh  Netherlands  Super 12  Netherlands   

  toss decision  first innings score  first innings wickets  \
0         Field                200.0                    3.0   
1         Field                112.0                   10.0   
2           Bat                128.0                    8.0   
3         Field                159.0                    8.0   
4         Field                144.0                    8.0   

   second innings score  second innings wickets       winner   won by  \
0                 111.0                    10.0  New Zealand     Runs   
1                 113.0                     5.0      England  Wickets   
2                 133.0                     1.0    Sri lanka  Wickets   
3                 160.0                     6.0        India  Wickets   
4                 135.0                    10.0   Bangladesh     Runs   

  player of the match       top scorer  highest score         best bowler  \
0        Devon Conway     Devon Conway           92.0         Tim Southee   
1          Sam Curran   Ibrahim Zadran           32.0          Sam Curran   
2        Kusal Mendis     Kusal Mendis           68.0  Maheesh Theekshana   
3         Virat Kohli      Virat Kohli           82.0       Hardik Pandya   
4        Taskin Ahmed  Colin Ackermann           62.0        Taskin Ahmed   

  best bowling figure  
0                 3-6  
1                5-10  
2                2-19  
3                3-30  
4                4-25  
In [3]:
# Checking Number of Matches Won by each teams

figure = px.bar(data, 
                x=data["winner"],
                title="Number of Matches Won by teams in t20 World Cup 2022")
figure.show()
In [ ]:
#England won most of the matches including final
In [4]:
#Winning team by First vs Second batting

won_by = data["won by"].value_counts()
label = won_by.index
counts = won_by.values

fig = go.Figure(data=[go.Pie(labels=label, values=counts)])
fig.update_layout(title_text='Number of Matches Won By Runs Or Wickets')

fig.show()
In [ ]:
#Batting first team has more percentange of win
In [5]:
#Looking at Toss decisions
toss = data["toss decision"].value_counts()
label = toss.index
counts = toss.values
colors = ['skyblue','yellow']

fig = go.Figure(data=[go.Pie(labels=label, values=counts)])
fig.update_layout(title_text='Toss Decisions in t20 World Cup 2022')
fig.update_traces(hoverinfo='label+percent', textinfo='value', textfont_size=30,
                  marker=dict(colors=colors, line=dict(color='black', width=3)))
fig.show()
In [ ]:
#Most of the teams chose batting after winning toss
In [6]:
#Looking at Top Batsman

figure = px.bar(data, 
                x=data["top scorer"], 
                y = data["highest score"],
                color = data["highest score"],
                title="Top Scorers in t20 World Cup 2022")
figure.show()
In [ ]:
#Virat kohli has most runs and Rilee Rossouw has highest run in single match
In [7]:
#Player of the match

figure = px.bar(data, 
                x = data["player of the match"], 
                color = data["player of the match"],
                title="Player of the Match Awards in t20 World Cup 2022")
figure.show()
In [8]:
#Best bowler in the tournament

figure = px.bar(data, 
                x=data["best bowler"],
                title="Best Bowlers in t20 World Cup 2022")
figure.show()
In [ ]:
#Sam curran got  player of the tournament award and having best bowling figures
In [9]:
#First innings vs Second innings


fig = go.Figure()
fig.add_trace(go.Bar(
    x=data["venue"],
    y=data["first innings score"],
    name='First Innings Runs',
    marker_color='green'
))
fig.add_trace(go.Bar(
    x=data["venue"],
    y=data["second innings score"],
    name='Second Innings Runs',
    marker_color='red'
))
fig.update_layout(barmode='group', 
                  xaxis_tickangle=-45, 
                  title="Best Stadiums to Bat First or Chase")
fig.show()
In [ ]:
#SCG is the Best Stadium for Batting whereas other stadium doesnt have much difference
In [10]:
fig = go.Figure()
fig.add_trace(go.Bar(
    x=data["venue"],
    y=data["first innings wickets"],
    name='First Innings Wickets',
    marker_color='green'
))
fig.add_trace(go.Bar(
    x=data["venue"],
    y=data["second innings wickets"],
    name='Second Innings Wickets',
    marker_color='red'
))
fig.update_layout(barmode='group', 
                  xaxis_tickangle=-45, 
                  title="Best Statiums to Bowl First or Defend")
fig.show()
In [ ]:
#SCG Stadium is good to defend runs and Optus Stadium is good for Second innings batting team
In [ ]: